<template>
	<view class="container">
		<swiper class="container" :autoplay="true" :interval="2000" :duration="1000">
			<swiper-item v-for="(v,i) in advertList" :key="i">
				<image :src="base_static+v.img" mode="aspectFill"></image>
			</swiper-item>
		</swiper>
		<!-- 跳过按钮 -->
		<view class="skip_box" @click="toNextpage">
			跳过
		</view>


	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from "vue"
	import {
		onLoad,onShow
	} from "@dcloudio/uni-app"
	// 首页广告
	import {
		getAdver
	} from "@/api/index.js"
	import * as S from "@/utils/storage.js"
	import { useCache } from "@/hooks/useCache"
	const Cache = useCache()
	onLoad(() => {
		getAdvertisement()
	})
	onShow(()=>{
		let flag = S.getItem("jumpFlag")
		console.log(flag,35)
		if(flag){
			uni.navigateTo({
				url: '/pagesA/home/home'
			})
		}
	})
	// const {
	// 	base_static
	// } = getCurrentInstance()?.appContext.config.globalProperties
	// 定义广告图片列表
	const advertList = ref([])

	// 获取广告数据
	function getAdvertisement() {
		Cache.get(()=>getAdver(),'pageIndexAd',0.125).then(res=>{
			advertList.value = res.data
		})
		
		getAdver().then(e=>{
			console.log(e,57)
		})
	}
	// 跳转页面
	function toNextpage() {
		S.setItem("jumpFlag",true,1)
		uni.navigateTo({
			url: '/pagesA/home/home'
		})
	}
</script>

<style lang="less">
	.container {
		position: relative;

		swiper-item,
		image {
			width: 100%;
			height: 100%;
			position: relative;
			z-index: 1;
		}

		.skip_box {
			position: fixed;
			/* #ifdef H5 */
			top: 5%;
			/* #endif */
			/* #ifdef MP-WEIXIN */
			top: 10%;
			/* #endif */
			right: 5%;
			border-radius: 50rpx;
			width: 150rpx;
			color: #fff;
			font-size: 34rpx;
			border: 1rpx solid #fff;
			line-height: 60rpx;
			background: rgba(250, 250, 250, .2);
			text-align: center;

		}
	}
</style>